﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using PPAP.Model;
using PPAP.DAO;

namespace PPAP.BO
{
    public class MailTemplateBO
    {
        public MailTemplateBO() { }
        MailTemplateDAO dao = new MailTemplateDAO();

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(MailTemplate model)
        {
            return dao.Add(model);
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public int Update(MailTemplate model)
        {
            return dao.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public int Delete(int id)
        {
            return dao.Delete(id);
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MailTemplate GetModel(int id)
        {
            return dao.GetModel(id);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dao.GetList(strWhere);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MailTemplate GetModelForUse()
        {
            return dao.GetModelForUse();
        }

        /// <summary>
        /// 得到邮件模板内容
        /// </summary>
        /// <param name="Body"></param>
        /// <returns></returns>
        public string GetMailText(string Body,ref string title)
        {
            MailTemplate mail = GetModelForUse();
            if (mail != null)
            {
                title = mail.TITLE;
                return mail.CONTENT.Replace("{Text}", Body);
            }
            else
                return Body;
        }

        /// <summary>
        /// 根据pparID获取partno,partname,qe-email
        /// </summary>
        /// <param name="pparid"></param>
        /// <returns></returns>
        public DataSet GetEDM2(string pparid)
        {
            return dao.GetEDM2(pparid);
        }

        /// <summary>
        /// 根据pparid获取partno,partname,supplier-email  edm3,edm4,edm5,edm12,edm13
        /// </summary>
        /// <param name="pparid"></param>
        /// <returns></returns>
        public DataSet GetEDM3(string pparid)
        {
            return dao.GetEDM3(pparid);
        }

        /// <summary>
        /// 根据pparid获取partno,partname,te-email  dem6
        /// </summary>
        /// <param name="pparid"></param>
        /// <returns></returns>
        public DataSet GetEDM6(string samplecardid)
        {
            return dao.GetEDM6(samplecardid);
        }

        /// <summary>
        /// 根据samplecardid获取partno,partname,te的上级tm-email  dem8
        /// </summary>
        /// <param name="samplecardid"></param>
        /// <returns></returns>
        public DataSet GetEDM8(string samplecardid)
        {
            return dao.GetEDM8(samplecardid);
        }

        /// <summary>
        /// 根据samplecardid获取partno,partname,te的上级tm-email  dem8  德国TM
        /// </summary>
        /// <param name="samplecardid"></param>
        /// <returns></returns>
        public DataSet GetEDM82(string samplecardid)
        {
            return dao.GetEDM82(samplecardid);
        }

        /// <summary>
        /// 根据samplecardid获取partno,partname,qe-email  dem9
        /// </summary>
        /// <param name="samplecardid"></param>
        /// <returns></returns>
        public DataSet GetEDM9(string samplecardid)
        {
            return dao.GetEDM9(samplecardid);
        }

        /// <summary>
        /// 根据pparid获取partno,partname,qe上级qm-email dem10
        /// </summary>
        /// <param name="pparid"></param>
        /// <returns></returns>
        public DataSet GetEDM10(string pparid)
        {
            return dao.GetEDM10(pparid);
        }

        /// <summary>
        /// 根据pparid获取partno,partname,qe-email
        /// </summary>
        /// <param name="pparid"></param>
        /// <returns></returns>
        public DataSet GetEDM14(string pparid)
        {
            return dao.GetEDM14(pparid);
        }

        /// <summary>
        /// 根据pparid获取partno,partname
        /// </summary>
        /// <param name="pparid"></param>
        /// <returns></returns>
        public DataSet GetEDM11(string pparid)
        {
            return dao.GetEDM11(pparid);
        }

        /// <summary>
        /// 根据pparID获取partno,partname,supplieradmin-email  edm17
        /// </summary>
        /// <param name="pparid"></param>
        /// <returns></returns>
        public DataSet GetEDM17(string pparid)
        {
            return dao.GetEDM17(pparid);
        }

    }
}
